#include "Objets.h"

Objets::Objets(string nom,string effet,string cible,int montant,string description, int quantite)
:nom(nom),montant(montant),description(description), quantite(quantite)
{
    if(effet == "Positif")
        this->effet = Positif;
    else
        this->effet = Negatif;

    if( cible== "PV")
        this->cible = PV;
    else if(cible=="PM")
        this->cible = PM;
    else if(cible == "FOR")
        this->cible = FOR;
    else
        this->cible = DEF;
}

Objets::~Objets()
{
    //dtor
}

void Objets::afficher()
{
    cout << "nom : " << nom << endl
         << "effet : " <<effet << endl
         << "cible : " <<cible   << endl
         << "montant : " <<montant << endl
         << "description : " <<description << endl
         << "quantite : "<<quantite << endl
         << endl;

}


void Objets::addQuantity(int i)
{
    quantite += i;
}
void Objets::use(Fighter& perso)
{
    if(quantite>=1)
    {
        if(effet==Positif)
        {
            switch (cible)
            {
                case PV: {perso.setPv( perso.getPv()+montant); break;}
                case PM: {perso.setPm( perso.getPm()+montant); break;}
                case FOR: {perso.setForce( perso.getForce()+montant); break;}
                case DEF: {perso.setDefense( perso.getDefense()+montant); break;}
            }
        }
        else
        {
            switch (cible)
            {
                case PV: {perso.setPv( perso.getPv()-montant); break;}
                case PM: {perso.setPm( perso.getPm()-montant); break;}
                case FOR: {perso.setForce( perso.getForce()-montant); break;}
                case DEF: {perso.setDefense( perso.getDefense()-montant); break;}
            }
        }
        quantite--;
    }
}
